home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / ultqsrc.zip / MONSTERS.QC < prev    next >
Text File  |  1996-09-16  |  5KB  |  247 lines

  1. /* ALL MONSTERS SHOULD BE 1 0 0 IN COLOR */
  2.  
  3. // name =[framenum,    nexttime, nextthink] {code}
  4. // expands to:
  5. // name ()
  6. // {
  7. //        self.frame=framenum;
  8. //        self.nextthink = time + nexttime;
  9. //        self.think = nextthink
  10. //        <code>
  11. // };
  12.  
  13. /*
  14. ================
  15. monster_use
  16.  
  17. Using a monster makes it angry at the current activator
  18. ================
  19. */
  20. void() monster_use =
  21. {
  22.     if (self.enemy)
  23.         return;
  24.     if (self.health <= 0)
  25.         return;
  26.     if (activator.items & IT_INVISIBILITY)
  27.         return;
  28.     if (activator.flags & FL_NOTARGET)
  29.         return;
  30.     if (activator.classname != "player")
  31.         return;
  32.     
  33. // delay reaction so if the monster is teleported, its sound is still
  34. // heard
  35.     self.enemy = activator;
  36.     self.nextthink = time + 0.1;
  37.     self.think = FoundTarget;
  38. };
  39.  
  40. /*
  41. ================
  42. monster_death_use
  43.  
  44. When a monster dies, it fires all of its targets with the current
  45. enemy as activator.
  46. ================
  47. */
  48. void() monster_death_use =
  49. {
  50.     local entity     ent, otemp, stemp;
  51. // fall to ground
  52.     if (self.flags & FL_FLY)
  53.         self.flags = self.flags - FL_FLY;
  54.     if (self.flags & FL_SWIM)
  55.         self.flags = self.flags - FL_SWIM;
  56.  
  57.     if (!self.target)
  58.         return;
  59.  
  60.     activator = self.enemy;
  61.     SUB_UseTargets ();
  62. };
  63.  
  64.  
  65. //============================================================================
  66.  
  67. void() walkmonster_start_go =
  68. {
  69. local string    stemp;
  70. local entity    etemp;
  71.  
  72.         if (!self.charmed)
  73.                 self.controller = self;
  74.  
  75.     self.origin_z = self.origin_z + 1;    // raise off floor a bit
  76.     droptofloor();
  77.     
  78.     if (!walkmove(0,0))
  79.     {
  80.         dprint ("walkmonster in wall at: ");
  81.         dprint (vtos(self.origin));
  82.         dprint ("\n");
  83.     }
  84.     
  85.     self.takedamage = DAMAGE_AIM;
  86.  
  87.     self.ideal_yaw = self.angles * '0 1 0';
  88.     if (!self.yaw_speed)
  89.         self.yaw_speed = 20;
  90.     self.view_ofs = '0 0 25';
  91.     self.use = monster_use;
  92.     
  93.     self.flags = self.flags | FL_MONSTER;
  94.      
  95.      if (self.target)
  96.      {
  97.          self.goalentity = self.movetarget = find(world, targetname, self.target);
  98.                 self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
  99.          if (!self.movetarget)
  100.          {
  101.              dprint ("Monster can't find target at ");
  102.                         dprint (vtos(self.origin));
  103.             dprint ("\n");
  104.         }
  105. // this used to be an objerror
  106.         if (self.movetarget.classname == "path_corner")
  107.             self.th_walk ();
  108.         else
  109.             self.pausetime = 99999999;
  110.             self.th_stand ();
  111.     }
  112.     else
  113.     {
  114.         self.pausetime = 99999999;
  115.         self.th_stand ();
  116.     }
  117.  
  118.         if (self.charmed)
  119.                 FindTarget();
  120. // spread think times so they don't all happen at same time
  121.     self.nextthink = self.nextthink + random()*0.5;
  122. };
  123.  
  124.  
  125. void() walkmonster_start =
  126. {
  127. // delay drop to floor to make sure all doors have been spawned
  128. // spread think times so they don't all happen at same time
  129.  
  130.     self.nextthink = self.nextthink + random()*0.5;
  131.     self.think = walkmonster_start_go;
  132.     total_monsters = total_monsters + 1;
  133. };
  134.  
  135.  
  136.  
  137. void() flymonster_start_go =
  138.  
  139. {
  140.         if (!self.charmed)
  141.                 self.controller = self;
  142.     self.takedamage = DAMAGE_AIM;
  143.  
  144.     self.ideal_yaw = self.angles * '0 1 0';
  145.     if (!self.yaw_speed)
  146.         self.yaw_speed = 10;
  147.     self.view_ofs = '0 0 25';
  148.     self.use = monster_use;
  149.  
  150.     self.flags = self.flags | FL_FLY;
  151.     self.flags = self.flags | FL_MONSTER;
  152.  
  153.     if (!walkmove(0,0))
  154.     {
  155.         dprint ("flymonster in wall at: ");
  156.         dprint (vtos(self.origin));
  157.         dprint ("\n");
  158.     }
  159.  
  160.     if (self.target)
  161.     {
  162.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  163.         if (!self.movetarget)
  164.         {
  165.             dprint ("Monster can't find target at ");
  166.             dprint (vtos(self.origin));
  167.             dprint ("\n");
  168.         }
  169. // this used to be an objerror
  170.         if (self.movetarget.classname == "path_corner")
  171.             self.th_walk ();
  172.         else
  173.             self.pausetime = 99999999;
  174.             self.th_stand ();
  175.     }
  176.     else
  177.     {
  178.         self.pausetime = 99999999;
  179.         self.th_stand ();
  180.     }
  181. };
  182.  
  183. void() flymonster_start =
  184. {
  185. // spread think times so they don't all happen at same time
  186.     self.nextthink = self.nextthink + random()*0.5;
  187.     self.think = flymonster_start_go;
  188.     total_monsters = total_monsters + 1;
  189. };
  190.  
  191.  
  192. void() swimmonster_start_go =
  193. {
  194.     if (deathmatch)
  195.     {
  196.         remove(self);
  197.         return;
  198.     }
  199.  
  200.         if (!self.charmed)
  201.                 self.controller = self;
  202.  
  203.     self.takedamage = DAMAGE_AIM;
  204.     total_monsters = total_monsters + 1;
  205.  
  206.     self.ideal_yaw = self.angles * '0 1 0';
  207.     if (!self.yaw_speed)
  208.         self.yaw_speed = 10;
  209.     self.view_ofs = '0 0 10';
  210.     self.use = monster_use;
  211.     
  212.     self.flags = self.flags | FL_SWIM;
  213.     self.flags = self.flags | FL_MONSTER;
  214.  
  215.     if (self.target)
  216.     {
  217.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  218.         if (!self.movetarget)
  219.         {
  220.             dprint ("Monster can't find target at ");
  221.             dprint (vtos(self.origin));
  222.             dprint ("\n");
  223.         }
  224. // this used to be an objerror
  225.         self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
  226.         self.th_walk ();
  227.     }
  228.     else
  229.     {
  230.         self.pausetime = 99999999;
  231.         self.th_stand ();
  232.     }
  233.  
  234. // spread think times so they don't all happen at same time
  235.     self.nextthink = self.nextthink + random()*0.5;
  236. };
  237.  
  238. void() swimmonster_start =
  239. {
  240. // spread think times so they don't all happen at same time
  241.     self.nextthink = self.nextthink + random()*0.5;
  242.     self.think = swimmonster_start_go;
  243.     total_monsters = total_monsters + 1;
  244. };
  245.  
  246.  
  247.